<%--
  Created by IntelliJ IDEA.
  User: 86138
  Date: 2022/4/1
  Time: 10:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    pageContext.setAttribute("APP_PATH",request.getContextPath());
%>
<html>
<head>
    <title>Title</title>
</head>
<link  rel="styleSheet" type="text/css" href="${APP_PATH}/dist/css/bootstrap.css"/>
<link  rel="styleSheet" type="text/css" href="${APP_PATH}/dist/css/style.css"/>
<body>

<!-- Button trigger modal -->


<!-- Modal -->
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">app表单注册</h4>
            </div>
            <div class="modal-body">
                <form id="formz">
                    <div class="form-group">
                        <label for="exampleInputEmail1">账号</label>
                        <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email" name="name">
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">密码</label>
                        <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password" name="pwd">
                    </div>
                </form>
                    <div class="checkbox">
                        <label>
                            <input type="checkbox"> Check me out
                        </label>
                    </div>
                    <%--<button type="button" class="btn btn-default" id="login">登录</button>--%>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
                <button type="button" class="btn btn-primary" id="login">注册</button>
            </div>
        </div>
    </div>
</div>


<section class="main">
    <div class="logo text-center">
        <h1> <a> 开发者平台管理系统</a></h1>
    </div>
    <div class="content-w3ls text-center">
        <img src="${APP_PATH}/dist/images/admin.png" alt="" class="img-responsive">
        <form action="#" method="post" id="logfrom">
            <div class="wthree-field">
                <input name="name" id="text1" type="text" value="" placeholder="Username" required>
            </div>
            <div class="wthree-field">
                <input name="pwd" id="myInput" type="Password" placeholder="Password">
            </div>
        </form>
            <div class="wthree-field">
                <button type="submit" class="btn" id="log">登录</button>
            </div>
            <div class="wthree-field">
                <button type="button" class="btn btn-primary btn-lg" id="addBtn" data-toggle="modal" data-target="#myModal">注册</button>
            </div>

    </div>
    <div class="copyright">
        <p>© 2022 潮人小分队版权所有 </p>
    </div>
</section>
<script type="text/javascript" src="${APP_PATH}/dist/js/jquery-1.12.4(1).js"></script>
<%--bootstrap的插件是依赖于jquery的--%>

<script type="text/javascript" src="${APP_PATH}/dist/js/bootstrap.min.js"></script>
<script type="text/javascript">

    //添加的模态框
    $("#addBtn").click(function () {
        $("#addModal").modal({
            backdrop:"static" //点击背景 模态框不消失
        });
    })

    $("#log").click(function () {
        console.log($("#logfrom").serialize())
        $.ajax({
            url:"${APP_PATH}/selectAppNP",
            type:"POST",
            data:$("#logfrom").serialize(),
            success:function (data) {
                console.log(data)

                alert(data.returnData.userInfo.gly)
                if (data.returnData.userInfo.gly==0){
                    location.href="${APP_PATH}/developer";
                }else {
                    alert("你不是开发者或者账号密码不正确")
                    location.href="${APP_PATH}";
                }

            }

        })
    })

    $("#login").click(function (){
        alert("aa")
        console.log($("#formz").serialize())
        $.ajax({
            url: "${APP_PATH}/addAppNp",
            type: "POST",
            data: $("#formz").serialize(),
            success:function (data){
                console.log(data)
                if (data.code==100){
                    alert("操作失败，密码不符合规则，或者重复")
                }else if(data.code==200){
                    alert("添加成功")
                }

            }
        })
    })


</script>
</body>

</html>
